package fw.qaz.asmx.reader.fragment;

import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import java.util.List;

import fw.qaz.asmx.reader.R;
import fw.qaz.asmx.reader.adapter.BookmarkAdapter;
import fw.qaz.asmx.reader.adapter.item.BookMarkItem;

public class BookmarkDialog extends DialogFragment
{
    private RecyclerView rv;
    private List<BookMarkItem> lst;
    private BookmarkAdapter bAdapter;

    public BookmarkDialog()
    {
    }

    @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState)
    {
        Dialog dg = new Dialog(getActivity());
        //
        dg.setContentView(R.layout.fragment_bookmark);
        rv = (RecyclerView) dg.findViewById(R.id.rv_bookmark);
        rv.setHasFixedSize(true);
        rv.setLayoutManager(new LinearLayoutManager(getActivity()));
        //
        bAdapter = new BookmarkAdapter(lst);
        bAdapter.setOnItemClickListener(new BookmarkAdapter.OnItemClickListener()
        {
            @Override public void onItemClick(View v, BookMarkItem bm, int pos)
            {
                //((MainActivity) getActivity()).startRead(bm.path, bm.get);
            }
        });
        rv.setAdapter(bAdapter);
        return dg;
    }
}
